home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / asm / music / sampleplayers / play_samples_irq2.s < prev   
Text File  |  1980-01-03  |  4KB  |  154 lines

  1. aud0        =    $a0
  2. aud1        =    $b0
  3. aud2        =    $c0
  4. aud3        =    $d0
  5. channel        =    16
  6. dmacon        =    $96
  7. ac_len        =    4
  8. ac_per        =    6
  9. ac_vol        =    8
  10. DMAF_SETCLR    =    $8000
  11.  
  12.         section    chipmem,code_c
  13.  
  14.         lea    $bfd000,a3
  15.         lea    $dff000,a6
  16.         move.b    #$7f,$d00(a3)
  17.         move.w    #$2000,$09c(a6)
  18.         move.w    #$a000,$09a(a6)
  19.         moveq    #0,d0
  20.         move.b    d0,$e00(a3)
  21.         move.b    #$a8,$400(a3)
  22.         move.b    d0,$500(a3)
  23.         move.b    #$11,$e00(a3)
  24.         move.b    #$81,$d00(a3)
  25.         
  26. aa        cmp.b    #100,$dff006
  27.         bne.s    aa
  28.         
  29.         btst    #7,$bfe001
  30.         bne.w    no_retrig
  31.  
  32.         move.w    #$f00,$dff180
  33.         lea    sample,a0        ;sample data ptr
  34.         move.l    #sampleend-sample,d0    ;sample length
  35.         suba.l    a1,a1            ;repeat data ptr
  36.         moveq    #0,d1            ;repeat length
  37.         moveq    #0*channel,d2        ;channel number (n x16)
  38.         move.w    #304,d3            ;sample frequency (note period)
  39.         move.w    #$40,d4            ;sample volume        
  40.         bsr    notestart
  41.         move.w    #$bbc,$dff180
  42.  
  43. ee        btst    #7,$bfe001
  44.         beq.s    ee
  45.         
  46. no_retrig
  47.         btst    #6,$bfe001
  48.         bne.w    aa
  49.  
  50. bb        rts
  51.  
  52. *******************************************************************************
  53. * NoteStart - Start playing a note immediately
  54. * ---------
  55. * $Inputs:    a0.l = One-shot sample data
  56. *        a1.l = Repeat sample data
  57. *        d0.l = One-shot sample length (0 if no one-shot part)
  58. *        d1.l = Repeat sample length (0 if no repeat part)
  59. *        d2.b = Channel number
  60. *        d3.w = Sample frequency (if 0, then high word contains period)
  61. *        d4.w = Volume at which to play sample (0-$100)
  62. * $Outputs:    None
  63. *******************************************************************************
  64.  
  65.         cnop    0,4
  66. notestop    moveq   #0,d0
  67.         move.l    d0,d1
  68.  
  69. NoteStart:    lea    $dff000,a6        * Set the repeat pointers
  70.         lea    aud0(a6),a5        * $dff0a0 base..
  71.         move.w    d1,d5            * copy of repeat length
  72.         or.w    d0,d5            * replen & sample len = 0 ?
  73.         bne.s    setnote            * if so.. turn off note..
  74.         moveq   #0,d0            * erase d0
  75.         bset    d2,d0            * set dma bit to turn off dma
  76.         move.w  d0,dmacon(a6)        * turn off channel..
  77.         rts
  78.  
  79.         cnop    0,4
  80. setnote:    add.w    d2,a5            * channel base $dff0a0/b0/c0/d0
  81.  
  82. *-------------- check for sample len..
  83.  
  84.             lsr.w    #1,d0            * Stuff the one-shot pointers
  85.                bne.s    hasoneshot
  86.                moveq    #2,d0            * sample length (set to none)
  87.             suba.l    a0,a0            * sample data   (set to none)
  88.  
  89. hasoneshot:    move.w    d3,ac_per(a5)        * set period
  90.             move.w    d4,ac_vol(a5)        * set volume
  91.         move.l  a0,(a5)            * set sample data ptr
  92.             move.w  d0,ac_len(a5)        * set sample length
  93.  
  94.             moveq   #0,d0            * Turn DMA for this channel off
  95.                bset    d2,d0
  96.                move.w  d0,dmacon(a6)        * do it..
  97.  
  98. *-------------- check for replen..
  99.  
  100.             lsr.w   #1,d1            * do sample repeat?
  101.             bne.s    hasrepeat
  102.             moveq   #2,d1            * repeat length (set to none)
  103.             suba.l    a1,a1            * repeat sample (set to none)
  104.  
  105. hasrepeat          lea     dmaflags(pc),a0
  106.             or.w    d0,(a0)            * save sample dma info..
  107.             move.b  d2,d0
  108.             move.w  d1,repeatlen-dmaflags(a0,d0.w*2)
  109.             move.l  a1,repeatptr-dmaflags(a0,d0.w*2)
  110.  
  111. *-------------- trigger sample dma on Level 6 IRQ...
  112.  
  113.         lea    mt_irq1(pc),a4
  114.         move.l    _vbr(pc),a1
  115.         move.l    a4,$78(a1)
  116.         or.w    #$8000,dmaflags
  117.         move.b    #$11,$bfde00
  118.         rts
  119.  
  120.         cnop    0,4
  121. mt_irq1        tst.b    $bfdd00
  122.         move.b    #$19,$bfde00
  123.         move.w    dmaflags(pc),$dff096
  124.         move.w    #$2000,$dff09c
  125.         move.l    a0,-(sp)
  126.         move.l    _vbr(pc),a0
  127.         add.l    #mt_irq2-mt_irq1,$78(a0)
  128.         move.l    (sp)+,a0
  129.         rte
  130.  
  131.         cnop    0,4
  132. mt_irq2        tst.b    $bfdd00
  133.         move.l    a6,-(sp)
  134.         lea    $dff000,a6
  135.             move.l  repeatptr+4*0(pc),aud0(a6)
  136.             move.w  repeatlen+2*0(pc),aud0+ac_len(a6)
  137.             move.l  repeatptr+4*1(pc),aud1(a6)
  138.             move.w  repeatlen+2*1(pc),aud1+ac_len(a6)
  139.             move.l  repeatptr+4*2(pc),aud2(a6)
  140.             move.w  repeatlen+2*2(pc),aud2+ac_len(a6)
  141.             move.l  repeatptr+4*3(pc),aud3(a6)
  142.             move.w  repeatlen+2*3(pc),aud3+ac_len(a6)
  143.         move.w    #$2000,$09c(a6)
  144.         move.l    (a7)+,a6
  145.         rte
  146.         
  147. dmaflags    ds.w    1
  148. repeatlen    ds.w    4
  149. repeatptr    ds.l    4
  150. _vbr        ds.l    1
  151.  
  152. sample        incbin    'atro:effects/lasertryr'
  153. sampleend
  154.